package com.ap.core.validation.message.rules;

import com.ap.core.message.managepayment.info.RetrieveRTPMessageInfo;
import com.ap.core.validation.message.info.MessageValidationInfo;
import com.ap.core.validation.message.info.RTPOriginalInfo;
import com.ap.core.validation.rules.AbstractValidationRule;

/**
 *  Check for the message field ApTransactionId will hold value only 
 * if the message field 'BRN' does not hold any value
 * @author Dilip.Sridhar
 *
 */
public class IF0008Rule  extends AbstractValidationRule<MessageValidationInfo<RetrieveRTPMessageInfo, RTPOriginalInfo>> {

    @Override
    public boolean validate(MessageValidationInfo<RetrieveRTPMessageInfo, RTPOriginalInfo> infoObject) {
        boolean pass = false;
        if(null == infoObject.getBoundObject().getRequestInfo().getBRN()) {        	
        	
        	pass = (null != infoObject.getBoundObject().getRequestInfo().getApTransactionId() && null != infoObject.getBoundObject().getRequestInfo().getApTRId());
        	
        } else if(null == infoObject.getBoundObject().getRequestInfo().getApTransactionId()  && null == infoObject.getBoundObject().getRequestInfo().getApTRId()) {
        	
        	pass = (null != infoObject.getBoundObject().getRequestInfo().getBRN());
        	
        }
        return pass;
    }

}